package com.example.foo.fttcard20220715.service;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.core.PageResult;
import com.example.core.Pageable;
import com.example.foo.fttcard20220715.model.FttCard20220715;
import com.example.foo.fttcard20220715.query.FttCard20220715Query;
import com.example.foo.fttcard20220715.dao.FttCard20220715Dao;

@Deprecated//TODO remove
@org.springframework.stereotype.Service
public class FttCard20220715Service {

	private final FttCard20220715Dao fttCard20220715Dao;

	public FttCard20220715Service(FttCard20220715Dao fttCard20220715Dao) {
		this.fttCard20220715Dao = fttCard20220715Dao;
	}

	// ========== FttCard20220715 ==========

	public PageResult<FttCard20220715> findFttCard20220715s(FttCard20220715Query fttCard20220715Query, Pageable pageable) {
		return fttCard20220715Dao.findFttCard20220715s(fttCard20220715Query, pageable);
	}

	public List<FttCard20220715> findFttCard20220715sByIds(List<Long> ids) {
		return fttCard20220715Dao.selectBatchIds(ids);
	}

	public FttCard20220715 findFttCard20220715ById(Long id) {
		return fttCard20220715Dao.selectById(id);
	}

	public FttCard20220715 findFttCard20220715ByCellphone(String cellphone) {
		return fttCard20220715Dao.selectOne(new QueryWrapper<FttCard20220715>()
				.eq("cellphone", cellphone)
				);
	}

	public void createFttCard20220715(String cellphone) {
		FttCard20220715 fttCard20220715 = new FttCard20220715();
		fttCard20220715.setCellphone(cellphone);
		fttCard20220715.setState(FttCard20220715.State.success);
		fttCard20220715.setCreatedAt(LocalDateTime.now());
		fttCard20220715Dao.insert(fttCard20220715);
	}

	public void updateFttCard20220715(Long id, FttCard20220715.State state) {
		FttCard20220715 fttCard20220715 = new FttCard20220715();
		fttCard20220715.setId(id);
		fttCard20220715.setState(state);
		fttCard20220715.setUpdatedAt(LocalDateTime.now());
		fttCard20220715Dao.updateById(fttCard20220715);
	}

}
